package com.aaa.sso.controller;

import com.aaa.common.entity.Users;
import com.aaa.sso.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * fileName:LoginController
 * description:
 * author:zz
 * createTime:2020/8/29 16:31
 * version:1.0.0
 */
@RestController
@RequestMapping("login")
public class LoginController {

    @Autowired
    private IUserService iUserService;

    /**
     * 用户认证
     * @param userName
     * @param passWord
     * @return
     */
    @GetMapping("checkUserInfo")
    public  String  checkUserInfo(String userName,String passWord){
           return iUserService.checkUserInfo(userName,passWord);
    }

    /**
     * 验证用户的唯一识别是否正确
     * @param accessToken
     * @return
     */
    @GetMapping("checkToken")
    public  boolean  checkToken(@RequestParam("accessToken") String accessToken){
        return iUserService.checkToken(accessToken);
    }

    /**
     * 根据accessToken获取用户信息
     * @param accessToken
     * @return
     */
    @GetMapping("getUserInfoByToken")
    public Users  getUserInfoByToken(@RequestParam("accessToken") String accessToken){
        return iUserService.getUserInfoByToken(accessToken);
    }

    /**
     * 用户注销方法
     * @param accessToken
     * @return
     */
    @GetMapping("userLogout")
    public String userLogout(String accessToken){
        return iUserService.userLogOut(accessToken);
    }
}
